import type { AppsType } from "@/store";

export const useApplication = () => {
    const modes = {
        SCAN_CODE: (app: AppsType) => {
            uni.scanCode({
                success: (res) => {
                    console.log(res);
                }
            });
        },
        LINK: (app: AppsType) => {
            uni.navigateTo({
                url: app.url
            });
        }
    };

    const onRunApplication = (application: AppsType) => {
        modes[application.mode](application);
    };

    return {
        onRunApplication
    };
};
